﻿#region Using References

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Beaker.OpenCube.CubeManager.Model.Framework;
using Beaker.OpenCube.CubeManager.Model.Interfaces;

#endregion

namespace Beaker.OpenCube.CubeManager.Model.Entities
{
	public class User
		: Entity, INamed
	{
		private readonly EntitySet<RoleSet, User> _roleSets;

		public User( string userName )
			: this()
		{
			Name = userName;
		}

		internal User()
		{
			_roleSets = new EntitySet<RoleSet, User>( this, ( set, user ) => set.User = user );
		}

		/// <summary>
		/// Gets or sets the name of this role.
		/// </summary>
		/// <value>
		/// The name of this role.
		/// </value>
		[StringLength( 64 )]
		[Required]
		public string Name { get; internal set; }

		/// <summary>
		/// Gets the set of role sets that are assigned to this user.
		/// </summary>
		/// <value>
		/// The set of role sets that are assigned to this user.
		/// </value>
		public ISet<RoleSet> RoleSets
		{
			get { return _roleSets; }
		}
	}
}
